package com.chixing.day20_annotation_jdk8;

import com.chixing.day06_static.word.Array;

import java.util.ArrayList;
import java.util.List;

class NumberThread implements Runnable{
    @Override
    public void run() {
        int a = 10;
        int b = 20;
        System.out.println("running");
    }
}

interface A{
    public void fun1();
}

interface B{
    public void fun2(int a,String b);
}

interface C{
    public int fun3(int a,float b);
}

interface D{
    public void fun4(int a);
}

public class LambdaDemo {
    public static void main(String[] args) {
        /*Thread thread = new Thread(new NumberThread());
        thread.start();*/

        //Lambda 表达式
        Runnable runnable =()-> {
            int a = 10;
            int b = 20;
            System.out.println("running");
        };
        Thread nthread = new Thread(runnable);
        nthread.start();

        A a = ()->{//fun(){}
            System.out.println("fun11");
            System.out.println("fun1..");
        };
        a.fun1();

        B b = (x,y)->{
            System.out.println("x:" +x);
            System.out.println("y:" +y);
        };
        b.fun2(10,"smith");

        C c = (i,j)-> {
            j = 20+i;
            return 2 * i;
        };
        int result = c.fun3(10,5.1f);
        System.out.println(result);

        D d = x-> System.out.println(x);//lambda表达式
        D d1 = System.out::println;//方法引用的写法（等价于 上面的东西）
        d.fun4(8);
        d1.fun4(12);

        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);

        list.forEach(System.out::println);
    }
}
